<script type="text/javascript" src="<?php echo ThemePath(); ?>/js/bootslider.js"></script>
<?php
$this->pageTitle = 'View My Course';
if (!isset($model->backendUser->username)) {
    $userid = $model->users->id;
    $profileData = Profiles::model()->find('user_id=:user_id ', array(':user_id' => (int) $userid));
    $uname = $profileData->first_name;
} else {
    $uname = $model->backendUser->username;
    $uid = $model->backendUser->id;
    $userid = 'backend/' . $uid;
}


$this->menu = array(
    array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('asigntotrainner')),
    array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')),
    array('label'=>Yii::t('app', 'Update') . ' ' . $model->label(), 'url'=>array('update', 'id' => $model->id)),
);
?>

<h3 style="text-align: left;"><?php echo Yii::t('app', 'View') . ' ' . GxHtml::encode($model->label()); ?></h3>
<h3 style="text-align: left;">Created By:<?php echo $uname; ?></h3>
<?php
$this->widget('zii.widgets.CDetailView', array(
    'data' => $model,
    'attributes' => array(
        'course_titile',
        'course_tag_description',
        array('name' => 'category_id', 'value' => $model->category->name,),
        array('name' => 'course_type_id', 'value' => $model->courseType->name,),
        array('name' => 'CoursesTargetAudiences', 'value' => Courses::getTargetAudience($model)),
        array('name' => 'difficulty_type', 'value' => ($model->difficulty_type == '1' ? 'Beginner' : ($model->difficulty_type == '2' ? 'Intermediate' : ($model->difficulty_type == '3' ? 'Advance' : 'No data')))),
        array('name' => 'course_short_description', 'type' => 'html', 'value' => $model->course_short_description,),
        array('name' => 'course_description', 'type' => 'html', 'value' => $model->course_description,),
        array('name' => 'course_outcome', 'type' => 'html', 'value' => $model->course_outcome,),
        array('name' => 'course_prerequisites', 'type' => 'html', 'value' => $model->course_prerequisites,),
        array('name' => 'course_other_information', 'type' => 'html', 'value' => $model->course_other_information,),
        array('name' => 'status', 'type' => 'image', 'htmlOptions' => array('class' => 'gridmaxwidth', 'style' => 'width: 15px !important'), 'value' => SkillConfig::status($model),),
        array('name' => 'certificate', 'value' => ($model->certificate == 1) ? 'Yes' : 'No',),
        'create_time',
        'update_time',
    ),
));
?>
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => 'View course Venues Batch Details',
));
$courseWithVenue = Courses::getCourseWithVenues($model->id);
$venueTotalCount = count($courseWithVenue);
$venueCount = 1;
/* -------------------- Loop for print Venue start------------------------------------ */
foreach ($courseWithVenue as $value) {
    $courseVenue = ClassVenue::model()->findbyPk($value['course_venue_id']);
    ?>
    <h3 style="text-align:left;"><?php echo 'Venue-' . $venueCount; ?>    </h3>
    <table class="table table-striped  table-bordered table-condensed">
        <tbody>
            <tr><td> Venue Name</td><td> Venue Locality </td><td>Address Line1</td><td>Address Line2</td><td>City</td><td>State</td> <td>Country</td><td>Zip Code</td></tr>
            <tr><td> <?php echo $courseVenue->name; ?></td><td> <?php echo $courseVenue->venue_locality; ?></td><td><?php echo $courseVenue->address_line1; ?></td><td><?php echo $courseVenue->address_line2; ?></td>
                <td><?php echo $courseVenue->city->city_name; ?></td><td><?php echo $courseVenue->state->name; ?></td> <td><?php echo $courseVenue->country->name; ?></td><td><?php echo $courseVenue->zip_code; ?></td></tr>

            <?php
            /* -------------------- Loop for print Batch details Start------------------------------------ */
            $courseStructure = Courses::getCoursesBatch($model->id, $value['course_venue_id']);
            $bacth = 1;
            foreach ($courseStructure as $batchValue) {
                ?>
                <tr><td colspan="7" style="background-color: blue;color: #fff;"><span class="classvenueView"><?php echo 'Batch-' . $bacth; ?> </span></td></tr>
                <tr><td colspan="7" style="background-color: #fff;">
                        <table class="table table-striped  table-bordered table-condensed">
                            <tbody>
                                <tr>  <td class="tdleft">Start date</td> <td class="tdleft">End Date</td><td class="tdleft">Price</td><td class="tdleft">Seats</td></tr>
                                <tr  style="background-color: #fff;"> <td class="tdleft"><?php echo $batchValue['date_from'] ?></td> <td class="tdleft"><?php echo $batchValue['date_to'] ?></td> <td class="tdleft"><?php echo $batchValue['price'] ?></td><td class="tdleft"><?php echo $batchValue['seats'] ?></td></tr>
                                <?php
                                /* --------------------  batch  EarlyDiscount  details Start------------------------------------ */
                                $courseEarlyDiscount = Courses::getCourseBatchEarlyBirdDiscount($model->id, $batchValue['id']);
                                $courseEarlyDiscountCount = count($courseEarlyDiscount);
                                ?>
                                <tr><td colspan="5" style="background-color: #a30c22"><span class="classvenueView"><?php echo 'Add Early Discounts(' . $courseEarlyDiscountCount . ')'; ?> </span></td></tr>
                                <tr>
                                    <td colspan="7">
                                        <table class="table table-striped table-hover table-bordered table-condensed">
                                            <tbody>
                                                <tr>  <td class="tdleft">Discount Price</td> <td class="tdleft">In Percentage</td><td class="tdleft">Valid To</td> </tr>
                                                <?php
                                                /* -------------------- Loop for EarlyDiscount print  details Start------------------------------------ */
                                                foreach ($courseEarlyDiscount as $courseEarlyValue) {
                                                    echo '<tr>  <td class="tdleft">' . $courseEarlyValue['discount_price'] . '</td> <td class="tdleft">' . $courseEarlyValue['in_percentage'] . '</td><td class="tdleft">' . $courseEarlyValue['valid_to'] . '</td> </tr>';
                                                }
                                                ?>

                                            </tbody>
                                        </table> 
                                    </td></tr><?php
                                        /* -------------------- Batch  EarlyDiscount  details End------------------------------------ */
                                        /* --------------------   Batch  GroupDiscount  details Start------------------------------------ */
                                        $courseGroupDiscount = Courses::getCourseBatchGroupDscount($model->id, $batchValue['id']);
                                        $courseGroupDiscountCount = count($courseGroupDiscount);
                                                ?>
                                <tr><td colspan="5" style="background-color: #4e4e4e"><span class="classvenueView"><?php echo 'Add Group Discounts(' . $courseGroupDiscountCount . ')'; ?> </span></td></tr>
                                <tr><td colspan="7"><table class="table table-striped table-hover table-bordered table-condensed">
                                            <tbody>
                                                <tr>  <td class="tdleft">Discount Price</td> <td class="tdleft">In Percentage</td><td class="tdleft">Group Zise</td> </tr>
                                                <?php
                                                /* -------------------- Loop for GroupDiscount print  details Start------------------------------------ */
                                                foreach ($courseGroupDiscount as $courseGroupValue) {
                                                    echo '<tr>  <td class="tdleft">' . $courseGroupValue['discount_amount'] . '</td> <td class="tdleft">' . $courseGroupValue['discount_in_percentage'] . '</td><td class="tdleft">' . $courseGroupValue['group_size'] . '</td> </tr>';
                                                }
                                                ?>
                                            </tbody></table></td></tr>
                                <?php
                                /* -------------------- Batch  GroupDiscount  details End------------------------------------ */
                                /* -------------------- Batch  Batche day & date  Sessions  details start------------------------------------ */
                                $customeDaysSessionForbatch = Courses::getCustomeSecheduleDaySession($model->id, $batchValue['id']);
                                $customedateSessionForbatch = Courses::getCustomeSecheduledateSession($model->id, $batchValue['id']);
                                if (!empty($customedateSessionForbatch)) {
                                    $customeDaysSession = $customedateSessionForbatch;
                                    $scheduletype = 'Date';
                                } else {
                                    $customeDaysSession = $customeDaysSessionForbatch;
                                    $scheduletype = 'Day';
                                }
                                ?>

                                <tr><td colspan="5" style="background-color: #4e4e4e"><span class="classvenueView"><?php echo 'Batche ' . $scheduletype . '  Sessions(' . count($customeDaysSession) . ')'; ?> </span></td></tr>
                                <tr><td colspan="7">
                                        <table class="table table-striped  table-bordered table-condensed">
                                            <tr> <td class="tdleft"><?php echo $scheduletype ?></td> <td class="tdleft">Start Time</td><td class="tdleft">End Time</td> <td class="tdleft">Flexible</td> </tr>
                                            <?php
                                            foreach ($customeDaysSession as $customeDayValue) {
                                                ?>
                                                <tr>  <td class="tdleft"><?php echo ($scheduletype == 'Day') ? Courses::getSchedulename($customeDayValue['schedule_id']) : $customeDayValue['date']; ?></td> <td class="tdleft"><?php echo $customeDayValue['time_from']; ?></td><td class="tdleft"><?php echo $customeDayValue['time_to']; ?></td> <td class="tdleft"><?php echo ($customeDayValue['is_flexible'] == '') ? 'No' : 'Yes'; ?></td> </tr>
                                                <?php
                                            }
                                            ?>
                                        </table></td></tr>
                                <?php /* -------------------- Batch  Batche day & date  Sessions  details start------------------------------------ */ ?>


                                <?php
                                $courseStructure = Courses::getCourseStructure($model->id, $batchValue['id']);
                                $courseStructureCount = count($courseStructure);
                                ?>

                                <tr><td colspan="5" style="background-color: #a30c22"><span class="classvenueView"><?php echo 'Course Structure(' . $courseStructureCount . ')'; ?> </span></td></tr>
                                <tr>								
                                    <td colspan="7">
                                        <table width="246" class="table table-striped  table-bordered table-condensed">
                                            <tbody>
                                                <tr>  <td class="tdleft">Start Time</td> <td class="tdleft">End Time</td><td class="tdleft">Description</td> </tr>


                                                <?php
                                                if (!empty($courseStructure)) {
                                                    foreach ($courseStructure as $value) {
                                                        ?><tr>  <td class="tdleft"><?php echo $value['start_time'] ?>&nbsp;&nbsp;Min</td> <td class="tdleft"><?php echo $value['end_time'] ?>&nbsp;&nbsp;Min</td> <td class="tdleft"><?php echo $value['description'] ?></td></tr>
                                                        <?php
                                                    }
                                                } else {
                                                    echo '<tr>No Course Structure Found</tr>';
                                                }
                                                ?>

                                            </tbody>
                                        </table> 
                                    </td></tr>




                            </tbody>
                        </table>


                        <?php
                        $bacth++;
                    }
                    ?>
        </tbody></table>    <hr class="hrclass"/><?php
                $venueCount++;
            }
            /* -------------------- Loop for print Venue End------------------------------------ */
                ?>

<?php
$this->endWidget();
?>




<?php
$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => 'View Fun and Learnings',
));
?>
<table class="table table-striped table-hover table-bordered table-condensed">
    <tbody>
        <tr><td class="tdleft">Fun Quotient</td> <td>Learn Quotient</td> </tr>
        <tr><td class="tdleft"> 
                <?php
                $funLearing = Classes::getfunlearing($model->id);
//echo $funLearing->fun;die;

                $this->widget('CStarRating', array(
                    'name' => 'FunLearning[fun]',
                    'value' => ($funLearing != '') ? $funLearing->fun : '',
                    'minRating' => 0.5,
                    'readOnly' => True,
                    'ratingStepSize' => 0.5,
                    'maxRating' => 5,
                ));
                ?>

            </td> <td> <?php
                $this->widget('CStarRating', array(
                    'name' => 'FunLearning[learn]',
                    'value' => ($funLearing != '') ? $funLearing->learn : '',
                    'minRating' => 0.5,
                    'readOnly' => True,
                    'ratingStepSize' => 0.5,
                    'maxRating' => 5,
                ));
                ?>
            </td> </tr>
    </tbody>

</table>
<?php
$this->endWidget();
?>

<?php
$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => 'View Course Images',
));
?>

<div style="width: 59%;margin: 0 auto;"> <?php
$courseWithImage = Courses::getCourseWithImage($model->id);

if (!empty($courseWithImage)) {
    ?>
        <div id="slider-fixed-banner" class="carousel slide">
            <div class="carousel-inner"><?php foreach ($courseWithImage as $value) { ?>               
                    <div class="<?php echo ($value['primary_image'] != '0') ? 'active' : ''; ?> item">
                        <?php echo '<img src="' . baseUrl() . '../../' .getUploadDir().SkillConfig::getClassCourseImagePath($userid) . 'details-image/' . $value['photo'] . '"  alt="">'; ?>
                    </div>
                <?php }
                ?>
            </div>

            <a class="left carousel-control" href="#slider-fixed-banner" data-slide="prev">&lsaquo;</a>
            <a class="right carousel-control" href="#slider-fixed-banner" data-slide="next">&rsaquo;</a>
        </div><?php
        }
            ?> 

</div>

<?php
$this->endWidget();
?>
